package com.ruoyi.enterprise.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.enterprise.domain.SResume;
import com.ruoyi.enterprise.service.ISResumeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 搜索平台人才Controller
 * 
 * @author jeffery
 * @date 2021-08-31
 */
@RestController
@RequestMapping("/enterprise/search")
public class SResumeSearchController extends BaseController
{
    @Autowired
    private ISResumeService sResumeService;

    /**
     * 查询简历信息列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:resume:list')")
    @GetMapping("/list")
    public TableDataInfo list(SResume sResume)
    {
        startPage();
        List<SResume> list = sResumeService.selectSResumeList(sResume);
        return getDataTable(list);
    }

    /**
     * 导出简历信息列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:resume:export')")
    @Log(title = "简历信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SResume sResume)
    {
        List<SResume> list = sResumeService.selectSResumeList(sResume);
        ExcelUtil<SResume> util = new ExcelUtil<SResume>(SResume.class);
        return util.exportExcel(list, "简历信息数据");
    }

    /**
     * 获取简历信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:resume:query')")
    @GetMapping(value = "/{resumeId}")
    public AjaxResult getInfo(@PathVariable("resumeId") Long resumeId)
    {
        return AjaxResult.success(sResumeService.selectSResumeByResumeId(resumeId));
    }

    /**
     * 新增简历信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:resume:add')")
    @Log(title = "简历信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SResume sResume)
    {
        return toAjax(sResumeService.insertSResume(sResume));
    }

    /**
     * 修改简历信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:resume:edit')")
    @Log(title = "简历信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SResume sResume)
    {
        return toAjax(sResumeService.updateSResume(sResume));
    }

    /**
     * 删除简历信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:resume:remove')")
    @Log(title = "简历信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{resumeIds}")
    public AjaxResult remove(@PathVariable Long[] resumeIds)
    {
        return toAjax(sResumeService.deleteSResumeByResumeIds(resumeIds));
    }
}
